package com.uyayo.portal.controller;

import com.uyayo.cms.entity.*;
import com.uyayo.cms.model.*;
import com.uyayo.cms.service.*;
import com.uyayo.framework.message.model.Result;
import com.uyayo.framework.pagehelper.pojo.PageBean;
import com.uyayo.framework.web.annotation.GetRequestInfo;
import com.uyayo.framework.web.model.RequestDefaultInfo;
import com.uyayo.portal.biz.CmsSiteBiz;
import com.uyayo.portal.biz.ParamBiz;
import com.uyayo.portal.exception.SiteNotFoundException;
import com.uyayo.portal.vo.*;
import com.uyayo.portal.wrap.CmsArticleWrap;
import com.uyayo.portal.wrap.CmsCommentWrap;
import com.uyayo.ucenter.entity.Member;
import com.uyayo.ucenter.entity.MemberVisitorLog;
import com.uyayo.ucenter.model.MemberVisitorLogCondition;
import com.uyayo.ucenter.service.MemberService;
import com.uyayo.ucenter.service.MemberVisitorLogService;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.dozer.DozerBeanMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.stereotype.Controller;
import org.springframework.validation.Errors;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import tk.mybatis.mapper.entity.Example;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;


/**
 *
 * <p>
 * Description:主页的Controller
 * </p>
 * <p>
 * Company: www.lelekeji.com
 * </p>
 * 
 * @author 乐乐科技.胡逢君
 * @date 2016-4-23下午4:03:35
 * @version 1.0
 */
@Controller
@RequestMapping()
public class IndexController {
	private final Logger logger = LoggerFactory.getLogger(this.getClass());

	private final ParamBiz paramBiz;

	private final CmsSiteBiz cmsSiteBiz;

	private final CmsSiteService cmsSiteService;

	private final CmsChannelService cmsChannelService;

	private final CmsArticleService cmsArticleService;

	private final CmsCommentService cmsCommentService;

	private final CmsReplyService cmsReplyService;

	private final  CmsArticleLikeService cmsArticleLikeService;

	private final  CmsCommentLikeService cmsCommentLikeService;

	private final  CmsReplyLikeService cmsReplyLikeService;

	private  final MessageSource messageSource;

	private final DozerBeanMapper dozerBeanMapper;

	private final CmsTagService cmsTagService;

	private final CmsArticleCategoryService cmsArticleCategoryService;

	private final MemberService memberService;

	private final MemberVisitorLogService memberVisitorLogService;

	@Autowired
	public IndexController(MessageSource messageSource, CmsArticleService cmsArticleService, CmsChannelService cmsChannelService, CmsSiteService cmsSiteService, CmsSiteBiz cmsSiteBiz, ParamBiz paramBiz, CmsCommentService cmsCommentService, CmsReplyService cmsReplyService, CmsArticleLikeService cmsArticleLikeService, CmsCommentLikeService cmsCommentLikeService, CmsReplyLikeService cmsReplyLikeService, DozerBeanMapper dozerBeanMapper, CmsTagService cmsTagService, CmsArticleCategoryService cmsArticleCategoryService, MemberService memberService, MemberVisitorLogService memberVisitorLogService) {
		this.messageSource = messageSource;
		this.cmsArticleService = cmsArticleService;
		this.cmsChannelService = cmsChannelService;
		this.cmsSiteService = cmsSiteService;
		this.cmsSiteBiz = cmsSiteBiz;
		this.paramBiz = paramBiz;
		this.cmsCommentService = cmsCommentService;
		this.cmsReplyService = cmsReplyService;
		this.cmsArticleLikeService = cmsArticleLikeService;
		this.cmsCommentLikeService = cmsCommentLikeService;
		this.cmsReplyLikeService = cmsReplyLikeService;
		this.dozerBeanMapper = dozerBeanMapper;
		this.cmsTagService = cmsTagService;
		this.cmsArticleCategoryService = cmsArticleCategoryService;
		this.memberService = memberService;
		this.memberVisitorLogService = memberVisitorLogService;
	}

	/**
	 *网站首页
	 */
	@RequestMapping(value={"index","index.html","/","","home.html"},method=RequestMethod.GET)
	public ModelAndView home_index(HttpServletRequest request,ModelAndView modelAndView,@RequestParam(value = "keyword",required = false) String keyword) {

		String server = request.getServerName();
		logger.info("通过域名访问网站首页[{}]",server);
		CmsSiteVO cmsSiteVO = cmsSiteBiz.getCmsSiteByDomain(server);
		if(cmsSiteVO==null) {
			throw new SiteNotFoundException(server);
		}
		if(!StringUtils.isBlank(keyword)) {
			return new ModelAndView("forward:/search");
		}
		modelAndView.setViewName(paramBiz.getWebsitTemplatesPrefix()+"index");
		return modelAndView;	
	}


	/**
	 * 频道页跳转-先转发到列表第一页
	 */
	@RequestMapping(value={"/ch/{channelDir}/index.html","/ch/{channelDir}/index","/ch/{channelDir}","/ch/{channelDir}.html"},method=RequestMethod.GET)
	public ModelAndView channel_list(ModelAndView modelAndView, @PathVariable("channelDir") String channelDir,@RequestParam(value="page", required=false, defaultValue="1") Integer page) {
		modelAndView.addObject("page",page);
		CmsChannel cmsChannel = new CmsChannel();
		cmsChannel.setChannelDir(channelDir);
		cmsChannel = cmsChannelService.selectOne(cmsChannel);

		CmsArticleCondition cmsArticleCondition = new CmsArticleCondition();
		cmsArticleCondition.setChannelId(cmsChannel.getId());
		PageBean<CmsArticle> pageBean = cmsArticleService.selectArticleByPaging(page,10,"createTime","desc",cmsArticleCondition);

		modelAndView.addObject("pageList",pageBean);
		modelAndView.addObject("cmsChannel",cmsChannel);
		modelAndView.setViewName(paramBiz.getWebsitTemplatesPrefix()+channelDir+"/index");
		return modelAndView;
	}

	/**
	 * 列表页跳转
	 */
	@RequestMapping(value={"/article/{channelDir}/list_{page}"},method=RequestMethod.GET)
	public ModelAndView list(ModelAndView modelAndView, @PathVariable("channelDir") String channelDir, @PathVariable Integer page) {
		modelAndView.addObject("page",page);
		CmsChannel cmsChannel = new CmsChannel();
		cmsChannel.setChannelDir(channelDir);
		cmsChannel = cmsChannelService.selectOne(cmsChannel);

		CmsArticleCondition cmsArticleCondition = new CmsArticleCondition();
		cmsArticleCondition.setChannelId(cmsChannel.getId());
		PageBean<CmsArticle> pageBean = cmsArticleService.selectArticleByPaging(page,10,"createTime","desc",cmsArticleCondition);

		modelAndView.addObject("pageList",pageBean);
		modelAndView.addObject("cmsChannel",cmsChannel);
		modelAndView.setViewName(paramBiz.getWebsitTemplatesPrefix()+channelDir+"/list");
		return modelAndView;
	}


	/**
	 * 内容页跳转
	 */
	@RequestMapping(value={"/article/detail/{id}"},method=RequestMethod.GET)
	public ModelAndView article(ModelAndView modelAndView, @RequestParam(value = "channelId") Long channelId, @PathVariable("id") Long id,HttpServletRequest request) {
		CmsChannel cmsChannel = new CmsChannel();
		cmsChannel.setId(channelId);
		cmsChannel = cmsChannelService.selectOne(cmsChannel);
		try {
			CmsArticle	cmsArticle = cmsArticleService.getArticleById(id);
			CmsArticle	cmsAfterArticle = cmsArticleService.getAfterArticle(id,cmsChannel.getId());
			CmsArticle	cmsPrevArticle = cmsArticleService.getPrevArticle(id,cmsChannel.getId());
			CmsArticleWrap cmsArticleWrap = dozerBeanMapper.map(cmsArticle, CmsArticleWrap.class);
			cmsArticleWrap.setCmsTags(cmsTagService.selectCmsTagListByArticleId(id));
			cmsArticleWrap.setCmsArticleCategories(cmsArticleCategoryService.selectCmsCategoryListByArticleId(id));

			modelAndView.addObject("cmsArticle",cmsArticleWrap);
			modelAndView.addObject("cmsAfterArticle",cmsAfterArticle);
			modelAndView.addObject("cmsPrevArticle",cmsPrevArticle);

			modelAndView.addObject("cmsChannel",cmsChannel);

			CmsCommentCondition cmsCommentCondition = new CmsCommentCondition();
			cmsCommentCondition.setArticleId(id);
			PageBean<CmsCommentBO> pageBean = cmsCommentService.selectCmsCommentListByPaging(0,10,"","",cmsCommentCondition);

			Subject subject = SecurityUtils.getSubject();
			List<CmsCommentLike> cmsCommentLikes = new ArrayList<>();
			if(subject.isAuthenticated()){
				Member member = (Member) subject.getPrincipal();
				Example example = new Example(CmsCommentLike.class);
				Example.Criteria criteria = example.createCriteria();
				criteria.andEqualTo("memberId",member.getId());
				List<Long> list = pageBean.getList().stream().map(CmsComment::getId).collect(Collectors.toList());
				if(list.size()>0) {
					criteria.andIn("commentId", list);
					example.createCriteria();
					cmsCommentLikes  = cmsCommentLikeService.selectByExample(example);
				}

			}

			List<CmsCommentLike> finalCmsCommentLikes = cmsCommentLikes;
			List<CmsCommentWrap> cmsCommentWraps= pageBean.getList().stream().map(cmsCommentBO -> {
				CmsCommentWrap cmsCommentWrap = dozerBeanMapper.map(cmsCommentBO,CmsCommentWrap.class);
					finalCmsCommentLikes.stream().anyMatch(cmsCommentLike -> {
						if(cmsCommentBO.getId().equals(cmsCommentLike.getCommentId()) && cmsCommentLike.getLikeType()==1){
							cmsCommentWrap.setLikeStatus(cmsCommentLike.getStatus());
						}
						if(cmsCommentBO.getId().equals(cmsCommentLike.getCommentId()) && cmsCommentLike.getLikeType()==2){
							cmsCommentWrap.setDislikeStatus(cmsCommentLike.getStatus());
						}
						return false;
					});
				return cmsCommentWrap ;
			}).collect(Collectors.toList());

			PageBean<CmsCommentWrap> cmsCommentWrapPageBean = new PageBean<>();
			cmsCommentWrapPageBean.setPageCurrent(pageBean.getPageCurrent());
			cmsCommentWrapPageBean.setPageSize(pageBean.getPageSize());
			cmsCommentWrapPageBean.setTotalCount(pageBean.getTotalCount());
			cmsCommentWrapPageBean.setTotalPage(pageBean.getTotalPage());
			cmsCommentWrapPageBean.setList(cmsCommentWraps);


			Member member = memberService.getMemberById(cmsArticle.getMemberId());
			modelAndView.addObject("cmsMember",member);

			CmsArticleCategoryCondition cmsArticleCategoryCondition = new CmsArticleCategoryCondition();
			cmsArticleCategoryCondition.setMemberId(member.getId());
			List<CmsArticleCategory>  cmsArticleCategoryList = cmsArticleCategoryService.selectArticleCategory(cmsArticleCategoryCondition);
			modelAndView.addObject("cmsArticleCategoryList",cmsArticleCategoryList);


			CmsArticleCondition cmsArticleRecommendCondition = new CmsArticleCondition();
			cmsArticleRecommendCondition.setChannelId(channelId);
			PageBean<CmsArticle> cmsArticleRecommendPageBean = cmsArticleService.selectArticleByPaging(1,10,"viewCount","desc",cmsArticleRecommendCondition);
			modelAndView.addObject("cmsArticleRecommendList",cmsArticleRecommendPageBean.getList());

			CmsArticleCondition cmsArticleNewCondition = new CmsArticleCondition();
			cmsArticleNewCondition.setChannelId(channelId);
			PageBean<CmsArticle> cmsArticleNewPageBean = cmsArticleService.selectArticleByPaging(1,10,"createTime","desc",cmsArticleNewCondition);
			modelAndView.addObject("cmsArticleNewList",cmsArticleNewPageBean.getList());

			PageBean<MemberVisitorLog> memberVisitorLogPageBean =new PageBean<>(1,9,"createTime","asc");
			MemberVisitorLogCondition memberVisitorLogCondition = new MemberVisitorLogCondition();
			memberVisitorLogCondition.setMemberId(member.getId());
			memberVisitorLogPageBean= memberVisitorLogService.selectMemberVisitorLogByPaging(memberVisitorLogPageBean,memberVisitorLogCondition);
			modelAndView.addObject("memberVisitorLogList",memberVisitorLogPageBean.getList());


			modelAndView.addObject("cmsCommentList",cmsCommentWrapPageBean);
			modelAndView.setViewName(paramBiz.getWebsitTemplatesPrefix()+cmsChannel.getChannelDir()+"/article");

		} catch (Exception e) {
			String message = messageSource.getMessage("server.error.500",new Object[]{}, request.getLocale());
			logger.error(message,e);
		}

		return modelAndView;
	}


    @ResponseBody
    @RequestMapping(method=RequestMethod.POST,value={"/article/like"})
    public Result like(HttpServletRequest request, @Validated CmsArticleLikeVO cmsArticleLikeVO, Errors errors, @GetRequestInfo RequestDefaultInfo requestInfo) {

        try {

            if (errors.hasErrors()) {
                return new Result(400,errors.getFieldError().getDefaultMessage());
            }
            Subject subject = SecurityUtils.getSubject();
            if(!subject.isAuthenticated()){
                String message = messageSource.getMessage("user.login",new Object[]{}, request.getLocale());
                logger.error(message);
                return new Result(5001,message);
            }
            Member member = (Member) subject.getPrincipal();
            CmsArticleLike cmsArticleLike = new CmsArticleLike();
			cmsArticleLike.setCreateTime(new Date());
			cmsArticleLike.setMemberId(member.getId());
			cmsArticleLike.setArticleId(cmsArticleLikeVO.getArticleId());
			cmsArticleLike.setLikeType(cmsArticleLikeVO.getLikeType());
			cmsArticleLike.setIp(requestInfo.getRequestIp());
			cmsArticleLike.setStatus(cmsArticleLikeVO.getStatus());
			cmsArticleService.like(cmsArticleLike);
            return new Result(200,"点赞成功！",request.getHeader("Referer"));
        }catch (Exception e) {
            String message = messageSource.getMessage("server.error.500",new Object[]{}, request.getLocale());
            logger.error(message,e);
            return new Result(400,message);
        }
    }


	@ResponseBody
	@RequestMapping(method=RequestMethod.GET,value={"/article/like"})
	public Result findArticleLike(Long articleId ,HttpServletRequest request) {

		try {

			Subject subject = SecurityUtils.getSubject();
			if(!subject.isAuthenticated()){
				String message = messageSource.getMessage("user.login",new Object[]{}, request.getLocale());
				logger.error(message);
				return new Result(5001,message);
			}
			Member member = (Member) subject.getPrincipal();
			CmsArticleLikeCondition cmsArticleLikeCondition = new CmsArticleLikeCondition();
			cmsArticleLikeCondition.setArticleId(articleId);
			cmsArticleLikeCondition.setMemberId(member.getId());
			cmsArticleLikeCondition.setStatus((short) 1);
			List<CmsArticleLike> cmsArticleLikeList = cmsArticleLikeService.selectCmsArticleLike(cmsArticleLikeCondition);
			return new Result(200,"查询成功！",cmsArticleLikeList);
		}catch (Exception e) {
			e.printStackTrace();
			return new Result(400,"查询失败，服务器发生异常，请管理员联系！");
		}
	}

	@ResponseBody
	@RequestMapping(method=RequestMethod.PUT,value={"/article/push-view-count"})
	public Result pushArticleViewCount(Long articleId) {

		try {
			CmsArticleCountBO cmsArticleCountBO = new CmsArticleCountBO();
			cmsArticleCountBO.setId(articleId);
			cmsArticleCountBO.setViewCount(1);
			int count = cmsArticleService.updateArticleCount(cmsArticleCountBO);
			return new Result(200,"递增成功！",count);
		}catch (Exception e) {
			e.printStackTrace();
			return new Result(400,"服务器发生异常，请管理员联系！");
		}
	}
	/**
	 * 站点首页
	 * @return
	 */
	/*@GetMapping("/${system.site.prefix}/{siteId}")
	public String index(@PathVariable("siteId") Integer siteId,
						Model model){
		log.debug("通过站点Id访问网站首页[{}]",siteId);
        *//*判断是否开启静态*//*
		File file = new File(PathUtil.getWebRootPath() +File.separator+ "html" + File.separator+ siteId + File.separator+"index.html");
		if (file.exists() && Boolean.parseBoolean(siteStatic)&& HtmlThread.size()<=0)
			return "redirect:/html/"+ siteId + "/index.html";
		TCmsSite site = siteService.findById(siteId);
		if(CmsUtil.isNullOrEmpty(site))
			throw new CmsException(CmsConst.SITE_NOT_FOUND);
		if(!site.getStatus())
			throw new CmsException(CmsConst.SITE_LOCKED);
		model.addAttribute("title",site.getTitle());
		model.addAttribute("keyword",site.getKeyword());
		model.addAttribute("description",site.getDescription());
		model.addAttribute("site",site);
		if(StrUtil.isBlank(site.getTemplate()))
			return view(CmsConst.INDEX_TPL);
		return view(site.getTemplate(),CmsConst.INDEX_TPL);
	}*/


	/*@GetMapping("/${system.site.prefix}/{siteId}/{categoryId}")
	public String category(@PathVariable("siteId") Integer siteId,
						   @PathVariable("categoryId") Long categoryId,
						   Model model){
		log.debug("栏目");
		TCmsSite site = siteService.findById(siteId);
		if(CmsUtil.isNullOrEmpty(site))
			throw new CmsException(CmsConst.SITE_NOT_FOUND);
		TCmsCategory category = categoryService.findById(categoryId);
		if(CmsUtil.isNullOrEmpty(category))
			throw new CmsException(CmsConst.CATEGORY_NOT_FOUND);
		PageInfo page = contentService.page(1,siteId,category.getCategoryId());
		model.addAttribute("title",category.getCategoryName());
		model.addAttribute("keyword",site.getKeyword());
		model.addAttribute("description",site.getDescription());
		model.addAttribute("site",site);
		model.addAttribute("category",category);
		model.addAttribute("page",page);
		if(StrUtil.isBlank(site.getTemplate()))
			return view(category.getIndexTpl());
		return view(site.getTemplate(),category.getIndexTpl());
	}

	*//*网站栏目列表页*//*
	@GetMapping("/${system.site.prefix}/{siteId}/{categoryId}/index_{pageNumber}")
	public String page(@PathVariable("siteId") Integer siteId,
					   @PathVariable("categoryId") Long categoryId,
					   @PathVariable(value = "pageNumber") Integer pageNumber,
					   Model model){
		log.debug("列表");
		TCmsSite site = siteService.findById(siteId);
		if(CmsUtil.isNullOrEmpty(site))
			throw new CmsException(CmsConst.SITE_NOT_FOUND);
		TCmsCategory category = categoryService.findById(categoryId);
		if(CmsUtil.isNullOrEmpty(category))
			throw new CmsException(CmsConst.CATEGORY_NOT_FOUND);
		if(CmsUtil.isNullOrEmpty(pageNumber))
			throw new CmsException(CmsConst.PAGE_NOT_FOUND);
		PageInfo page = contentService.page(pageNumber,siteId,category.getCategoryId());
		model.addAttribute("title",category.getCategoryName());
		model.addAttribute("keyword",site.getKeyword());
		model.addAttribute("description",site.getDescription());
		model.addAttribute("site",site);
		model.addAttribute("category",category);
		model.addAttribute("page",page);
		if(StrUtil.isBlank(site.getTemplate()))
			return view(category.getListTpl());
		return view(site.getTemplate(),category.getListTpl());
	}

	*//*网站内容页*//*
	@GetMapping("/${system.site.prefix}/{siteId}/{categoryId}/{contentId}")
	public String content(@PathVariable("siteId") Integer siteId,
						  @PathVariable("categoryId") Long categoryId,
						  @PathVariable("contentId") Long contentId,
						  Model model){
		TCmsSite site = siteService.findById(siteId);
		if(CmsUtil.isNullOrEmpty(site))
			throw new CmsException(CmsConst.SITE_NOT_FOUND);
		TCmsCategory category = categoryService.findById(categoryId);
		if(CmsUtil.isNullOrEmpty(category))
			throw new CmsException(CmsConst.CATEGORY_NOT_FOUND);
		TCmsModel contentModel = modelService.findById(category.getModelId());
		if(CmsUtil.isNullOrEmpty(category))
			throw new CmsException(CmsConst.PAGE_NOT_FOUND);
		Map content = contentService.findContentByContentIdAndTableName(contentId,contentModel.getTableName());
		if(CmsUtil.isNullOrEmpty(content))
			throw new CmsException(CmsConst.CONTENT_NOT_FOUND);
		contentService.viewUpdate(contentId);
		model.addAttribute("title",content.get("title"));
		model.addAttribute("keyword",content.get("keywords"));
		model.addAttribute("description",content.get("description"));
		model.addAttribute("site",site);
		model.addAttribute("category",category);
		model.addAttribute("content",content);
		if(StrUtil.isBlank(site.getTemplate()))
			return this.view(category.getContentTpl());
		return this.view(site.getTemplate(),category.getContentTpl());
	}

	*//*全文检索和模型字段检索*//*
	@RequestMapping("/search")
	public String search(@RequestParam(value = "keyword",required = false) String keyword,
						 @RequestParam(value = "m",defaultValue = "0") Integer modelId,
						 @RequestParam(value = "s",defaultValue = "0") Integer siteId,
						 @RequestParam(value = "c",defaultValue = "0") Long catId,
						 @RequestParam(value = "p",defaultValue = "1") Integer pageNumber,
						 HttpServletRequest request
	){
		log.debug("搜索");
		TCmsSite site = siteService.findById(siteId);
		if(CmsUtil.isNullOrEmpty(site))
			throw new CmsException(CmsConst.SITE_NOT_FOUND);
		if (modelId > 0 && catId > 0) {
			String action = httpProtocol + "://" + ControllerUtil.getDomain();
			action += "/search?m=" + modelId + "&c=" + catId;
			TCmsCategory category = categoryService.findById(catId);
			if(CmsUtil.isNullOrEmpty(category))
				throw new CmsException(CmsConst.CATEGORY_NOT_FOUND);
			TCmsModel model = modelService.findById(modelId);
			Map<String, Object> param = Maps.newHashMap();
			List<TCmsModelFiled> modelFileds = modelFiledService.findModelFiledListByModelId(modelId);
            *//* 循环检索获取filedName和fildValue*//*
			for (TCmsModelFiled filed : modelFileds) {
				String filedValue = request.getParameter(filed.getFiledName());
				if (!StrUtil.isBlank(filedValue)) {
					param.put(HtmlKit.getText(filed.getFiledName()).trim(), HtmlKit.getText(filedValue).trim());
					action += "&" + filed.getFiledName() + "=" + filedValue;
				}
			}
			PageInfo page = contentService.findContentListByModelFiledValue(pageNumber,catId,model.getTableName(), param);
			request.setAttribute("title",category.getCategoryName());
			request.setAttribute("keyword",site.getKeyword());
			request.setAttribute("description",site.getDescription());
			request.setAttribute("site", site);
			request.setAttribute("category", category);
			request.setAttribute("page", page);
			request.setAttribute("param", param);
			request.setAttribute("action", action);
			return view(site.getTemplate(), category.getListTpl());
		}else{
			String action = httpProtocol + "://" + ControllerUtil.getDomain();
			if(StrUtil.isBlank(keyword))
				throw new CmsException(CmsConst.SEARCH_KEYWORD_NOT_FOUND);
			action +="/search?keyword="+keyword;
			PageInfo page =luceneService.page(pageNumber,Integer.parseInt(this.pageSize),keyword);
			request.setAttribute("page",page);
			request.setAttribute("site",site);
			request.setAttribute("action", action);
			request.setAttribute("keyword", keyword);
			return view(site.getTemplate(), CmsConst.SEARCH_TPL);
		}
	}*/

	private String view(String viewName){
		return  this.view("default",viewName);
	}

	private String view(String theme,String viewName){
		return "www/"+theme.trim()+"/"+viewName.trim();
	}

}
